using SqlSugar;
using IM.Easy.Core.Audit;
using IM.Easy.Infrastructure.Query;
using IM.Easy.Entity.Scheduled;

namespace IM.Easy.ScheduledServices.Dtos
{
    /// <summary>
    /// 任务触发器表查询实体
    /// </summary>
    public class JobTriggerQueryDto : QueryBase
    {
    }

    /// <summary>
    /// 任务触发器表dto
    /// </summary>
    public class JobTriggerDto
    {
        /// <summary>
        /// 触发器唯一标识
        /// </summary>
        public Guid Id { get; set; }
        /// <summary>
        /// 关联任务的ID
        /// </summary>
        public Guid JobId { get; set; }
        /// <summary>
        /// 触发器类型，如 Cron 或 Simple
        /// </summary>
        public string Type { get; set; }
        /// <summary>
        /// Cron 表达式，用于 Cron 调度
        /// </summary>
        public string Cron { get; set; }
        /// <summary>
        /// 间隔时间（单位：秒），用于简单调度
        /// </summary>
        public int Interval { get; set; }

        /// <summary>
        /// 触发器是否启用（1：启用，0：禁用）
        /// </summary>
        public byte IsActive { get; set; }

        /// <summary>
        /// 轮询次数
        /// </summary>
        public int Repeat { get; set; }

        /// <summary>
        /// 有效期开始
        /// </summary>
        public DateTime? EffictStartTime { get; set; }

        /// <summary>
        /// 立马执行
        /// </summary>
        public bool Immediate
        {
            get
            {
                return !EffictStartTime.HasValue;
            }
        }

        /// <summary>
        /// 启动模式
        /// </summary>
        public TriggerStartMode StartMode { get; set; }

        /// <summary>
        /// 有效期结束
        /// </summary>
        public DateTime? EffictEndTime { get; set; }

        /// <summary>
        ///  永不截止
        /// </summary>
        public bool Forever
        {
            get
            {
                return !EffictEndTime.HasValue;
            }
        }




        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatedAt { get; set; }
        /// <summary>
        /// 创建人ID
        /// </summary>
        public long CreatedBy { get; set; }
        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdatedAt { get; set; }
        /// <summary>
        /// 更新人ID
        /// </summary>
        public long UpdatedBy { get; set; }
        /// <summary>
        /// 是否已删除
        /// </summary>
        public byte IsDeleted { get; set; }
        /// <summary>
        /// 删除人ID
        /// </summary>
        public long DeletedBy { get; set; }
        /// <summary>
        /// 删除时间
        /// </summary>
        public DateTime DeletedAt { get; set; }
    }
    /// <summary>
    /// 任务触发器
    /// </summary>
    public class JobTriggerCreateDto
    {
        /// <summary>
        /// 触发器唯一标识
        /// </summary>
        public Guid Id { get; set; }

        /// <summary>
        /// 关联任务的ID
        /// </summary>
        public Guid JobId { get; set; }

        /// <summary>
        /// 触发器类型，如 Cron 或 Simple
        /// </summary>
        public string Type { get; set; }

        /// <summary>
        /// Cron 表达式，用于 Cron 调度
        /// </summary>
        public string Cron { get; set; }

        /// <summary>
        /// 间隔时间（单位：秒），用于简单调度
        /// </summary>
        public int Interval { get; set; }

        /// <summary>
        /// 轮询次数
        /// </summary>
        public int Repeat { get; set; }

        /// <summary>
        /// 启动模式
        /// </summary>
        public TriggerStartMode StartMode { get; set; }

        /// <summary>
        /// 有效期开始
        /// </summary>
        public DateTime? EffictStartTime { get; set; }

        /// <summary>
        /// 有效期结束
        /// </summary>
        public DateTime? EffictEndTime { get; set; }

        /// <summary>
        /// 触发器是否启用（true：启用，false：禁用）
        /// </summary>
        public bool IsActive { get; set; }

    }
}
